import axios from "~/axios";
import {queryFilters} from "~/composables/util";

// 获取图库分类
// export function getImageLabelList({ ...data }) {
//     data['type_name'] = "图片库"
//     let r = queryFilters(data)
//     return axios.get(`/user/currency_label/${r}`)
// }

// 获取图片类型标签
export function getImageLabelList() {
    // data['type_name'] = "图片库"
    // let r = queryFilters(data)
    return axios.get(`/system/currency_label/?name=&label_type=0`)
}

// 获取图片类型标签
export function getVideoLabelList() {
    // data['type_name'] = "图片库"
    // let r = queryFilters(data)
    return axios.get(`/system/currency_label/?name=&label_type=1`)
}

// 新增图库分类
export function postImageLabel(data) {
    return axios.post('/system/currency_label/', data)
}

// 新增视频分类
export function postVideoLabel(data) {
    return axios.post('/system/currency_label/', data)
}

// 修改图库分类
export function patchImageLabel(id, data) {
    return axios.patch(`/system/currency_label/${id}/`, data)
}

// 删除图库分类
export function deleteImageLabel(id) {
    return axios.delete(`/system/currency_label/${id}/`)
}

// 获取分类的图库
export function getImageList(id, pageNo, pageSize, is_image = true) {
    let r = queryFilters({image_label_id: id, pageNo, pageSize})
    return axios.get(`/medias/image/${r}&is_image=${is_image}`)
}



// 获取分类的图库
export function getVideoList(id, pageNo, pageSize, is_image = false) {
    let r = queryFilters({image_label_id: id, pageNo, pageSize})
    return axios.get(`/medias/video/${r}&is_image=${is_image}`)
}

export function getObjects() {
    return axios.get(`/medias/image/`)
}

export function getVideo() {
    return axios.get(`/medias/video/`)
}


// 修改图库图片标题和标签
export function patchImageTitleOtLabel({id, title, image_label}) {
    return axios.patch(`/medias/image/${id}/`, {title, image_label})
}

// 修改图库图片标题和标签
export function patchVideoTitleOtLabel({id, title, image_label}) {
    return axios.patch(`/medias/video/${id}/`, {title, image_label})
}

// 删除图库图片
export function deleteImage(id) {
    return axios.delete(`/medias/image/${id}/`)
}

// 上传图库图片
export const uploadImageAction = import.meta.env.VITE_APP_BASE_API + "/medias/image/"